<?php
if (!defined('WEB_ROOT')) {
	exit;
}
$rowsPerPage = 5;
		$sql="SELECT idTin,TieuDe,TomTat,Ngay,SoLanXem,tin.AnHien,TinNoiBat,TenTL,Ten
			  FROM tin,theloai,loaitin
			  WHERE (tin.idTL=theloai.idTL) AND (tin.idLT=loaitin.idLT)
			  ORDER BY idTin DESC
			  LIMIT 0,10";
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
return 
?>
<style type="text/css">
#listNews{ margin:0px; padding:0px;}
form{ width:900px; margin:40px auto;}
</style>
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#chonhet").click(function(){
		var status=this.checked;
		$("input[name='chon']").each(function(){this.checked=status;});
		});//End #chonhet
		$("#xoahet").click(function(){
			var listid="";
			$("input[name='chon']").each(function(){
				if(this.checked) listid=listid + "," + this.value;
			});
			listid=listid.substr(1);
			if(listid==""){ alert("Chưa chọn tin nào ,sao mà xóa?"); return;}
			hoi=confirm("Delete all?");
			if(hoi==true) document.location="newsDelete.php?listid=" +listid;
		});//End #xoahet
	});

</script>
<body>
	<div id="listNews">
    	<form id="form1" name="form1" method="post" action="">
            <table id=dstin  border=1 cellpadding=4  cellspacing=0  width=800  align=center>
            <tr>
              <td colspan="3" align="left">
                  <input type="button" name="xoahet" id="xoahet" value=" Xoá " />
                  <input type="button" name="chinhhet" id="chinhhet" value="Chỉnh" />     
              </td>
              <td align="right"> 
            <select name="themtin" class="themtin" id="themtin">
                <option value="1">1</option> <option value="2">2</option>
                <option value="3">3</option> <option value="4">4</option>
                <option value="5">5</option>
            </select>
            <a href="#" onClick="return false" class="them" id="them">Thêm</a>
              </td>
            </tr>
            <tr>
               <th align="left"><input type="checkbox" name="chonhet" id="chonhet" /></th>
               <th> idTin/Ngày </th>
               <th> Tiêu đề/Tóm tắt </th>
               <th> Action </th>
            </tr>
            
            <!--bắt đầu lặp -->
            <?php while ($row_news=mysql_fetch_assoc($news)) {?>
            <?php ob_start(); ?>
            <tr class="hang">
               <td><input type="checkbox" name="chon" id="chon" value="{idTin}" class="chon" /></td>
               <td align="center" class="ngay">
                <span>idTin: {idTin} </span><br /> 
                <span>{Ngay} </span> <br /> 
            <span>Xem: {SoLanXem} </span>
               </td>
               <td class="tin" valign=top>
                 <p class="tieude">{TieuDe}   <span> ({TenTL} </span> / <span> {Ten}) </span> </p>
                 <p class="tomtat">{TomTat}</p> 
               </td>
               <td width="100" align="center" class="action">
                | <a href="../temp/tintuc_chinh1.php?idTin={idTin}">Chỉnh</a> 
                | <a href="delete.php?idTin={idTin}"  onclick="return confirm('Xoá hả');">Xóa</a> |
                  <a href="../temp/tintuc_xemchitiet.php?idTin={idTin}">Xem</a><br />
                  <img src="../temp/images/AnHien_{AnHien}.jpg" title="Ẩn hiện tin" class="anhien" value="{idTin}" />
                &nbsp; 
                <img src="../temp/NoiBat_{TinNoiBat}.jpg" title="Tin nổi bật" class="noibat" 	value="{idTin}">
               </td>
            </tr>
            <?php
				$str=ob_get_clean();
				$str=str_replace("{idTin}", $row_news['idTin'] , $str);
				$str=str_replace("{Ngay}",date('d/m/Y',strtotime($row_news['Ngay'])) , $str);
				$str=str_replace("{TieuDe}", $row_news['TieuDe'] , $str);
				$str=str_replace("{TomTat}", $row_news['TomTat'] , $str);
				$str=str_replace("{SoLanXem}", $row_news['SoLanXem'] , $str);
				$str=str_replace("{AnHien}", $row_news['AnHien'] , $str);
				$str=str_replace("{TinNoiBat}", $row_news['TinNoiBat'] , $str);
				$str=str_replace("{TenTL}", $row_news['TenTL'] , $str);
				$str=str_replace("{Ten}", $row_news['Ten'] , $str);
				echo $str;
			?>
            <?php }?>
            <!-- kết thúc lặp -->
            </table>
           </form>
   </div>
</body>
</html>